package com.whut.controller;

import com.whut.model.Judgeinfo;
import com.whut.model.Membershipinfo;
import com.whut.model.Fuzzyindicators;
import com.whut.model.Specialistinfo;
import com.whut.service.FuzzyService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * 模糊评价法模块
 *
 * @author fanyu
 * @date 2019/9/18 9:57
 */
@Controller
@RequestMapping("/fuzzy")
public class FuzzyController {
    @Resource
    private FuzzyService fuzzyService;

    @ResponseBody
    @PostMapping("/deleteMemberShipInfoBySpecialistId")
    public String deleteMemberShipInfoBySpecialistId(Integer specialistId) {
        fuzzyService.deleteMemberShipInfoBySpecialistId(specialistId);
        return "success";
    }

    @ResponseBody
    @PostMapping("/addJudgeInfo")
    public String addJudgeInfo(Judgeinfo judgeinfo) {
        fuzzyService.addJudgeInfo(judgeinfo);
        return "success";
    }

    @ResponseBody
    @PostMapping("/deleteBySpecialistId")
    public String deleteBySpecialistId(Integer specialistId,Integer id3) {
        fuzzyService.deleteBySpecialistId(specialistId,id3);
        return "success";
    }

    @ResponseBody
    @PostMapping("/importFileData")
    public String importFileData(List<Membershipinfo> list) {
//        fuzzyService.importFileData(list);
        return "success";
    }

    @ResponseBody
    @PostMapping("/addMemberShipInfo")
    public String addMemberShipInfo(Membershipinfo membershipinfo) {
        fuzzyService.addMemberShipInfo(membershipinfo);
        return "success";
    }

    @ResponseBody
    @PostMapping("/deleteMemberShipInfo")
    public String deleteMemberShipInfo(Integer mkey) {
        fuzzyService.deleteMemberShipInfo(mkey);
        return "success";
    }

    @ResponseBody
    @PostMapping("/editMemberShipInfo")
    public String editMemberShipInfo(Membershipinfo membershipinfo) {
        fuzzyService.editMemberShipInfo(membershipinfo);
        return "success";
    }

    /**
     * 分页获取专家信息
     *
     * @return java.lang.Object
     * @author fanyu
     * @date 2019/9/18 9:57
     * @params [curPage, pageSize]
     */
    @ResponseBody
    @PostMapping("/getAllSpecialistByPage")
    public Object getAllSpecialistByPage(int curPage, int pageSize) {
        return fuzzyService.getAllSpecialistByPage(curPage, pageSize);
    }

    /**
     * 通过专家Id获取其判断矩阵信息
     *
     * @return java.lang.Object(返回的对象中包含两个list, 分别是表头和表的内容)
     * @author fanyu
     * @date 2019/9/18 9:59
     * @params [specialistId]
     */
    @ResponseBody
    @PostMapping("/getJudgeInfo")
    public Object getAllJudgeInfo(int specialistId) {
        return fuzzyService.getAllJudgeInfo(specialistId);
    }

    /**
     * @Author chenhuanru
     * @Description //仿写的接口
     * @Date 20:16 2020/3/31
     * @Param [specialistId]
     * @return java.lang.Object
     **/

    @ResponseBody
    @PostMapping("/getJudgeInfo1")
    public Object getAllJudgeInfo1(int specialistId,int id3) {
        return fuzzyService.getAllJudgeInfo1(specialistId,id3);
    }

    /**
     * 根据判断矩阵的横纵坐标以及专家id,修改判断矩阵内容
     *
     * @return java.lang.String（是否成功信息）
     * @author fanyu
     * @date 2019/9/18 10:00
     * @params [id1, id2, point, specialistId]
     */
    @ResponseBody
    @PostMapping("/editJudgeInfo")
    public String editJudgeInfo(int id1, int id2, double point, int specialistId,int id3) {
        return fuzzyService.editJudgeInfo(id1, id2, point, specialistId,id3);
    }

    /**
     * 返回体系的前四级级联所需数据
     *
     * @return java.lang.Object
     * @author fanyu
     * @date 2019/9/18 10:02
     */
    @ResponseBody
    @PostMapping("/getChooseInfoForJudge")
    public Object getChooseInfoForJudge() {
        return fuzzyService.getChooseInfoForJudge();
    }

    /**
     * @Author chenhuanru
     * @Description //这是仿写的接口
     * @Date 18:03 2020/3/31
     * @Param []
     * @return java.lang.Object
     **/

    @ResponseBody
    @PostMapping("/getChooseInfoForJudge1")
    public Object getChooseInfoForJudge1(int preNum ,String nodeDepth) {
        return fuzzyService.getChooseInfoForJudge1(preNum,nodeDepth);
    }

    /**
     * 为判断矩阵加入一个检查项
     *
     * @return java.lang.String
     * @author fanyu
     * @date 2019/9/18 10:03
     * @params [specialistId, fourthId]
     */
    @ResponseBody
    @PostMapping("/addJudgeItems")
    public String addJudgeItems(int specialistId, int fourthId,int id3) {
        return fuzzyService.addJudgeItems(specialistId, fourthId,id3);
    }

    /**
     * 判断矩阵的一致性检验
     *
     * @return java.lang.Float
     * @author fanyu
     * @date 2019/9/18 20:01
     * @params [specialistId]
     */
    @ResponseBody
    @PostMapping("/consistCheck")
    public Float consistCheck(int specialistId,int id3) {
        return fuzzyService.consistCheck(specialistId,id3);
    }

    @ResponseBody
    @PostMapping("/getAllMembership")
    public Object getAllMembership(Integer specialistId) {
        return fuzzyService.getAllMembership(specialistId);
    }

    @ResponseBody
    @PostMapping("/updateZj")
    public String updateZj(Specialistinfo zj) {
        return fuzzyService.updateZj(zj);
    }

    /**
     * 返回各检查的专家判断矩阵因素权重总表
     *
     * @return java.lang.Object
     * @author fanyu
     * @date 2019/9/20 7:34
     * @params [checkId]
     */
    @ResponseBody
    @PostMapping("/getAllJudgeResult")
    public Object getAllJudgeResult(int checkId) {
        return fuzzyService.getAllJudgeResult(checkId);
    }
    /**
     * @Author chenhuanru
     * @Description //仿写的接口
     * @Date 19:07 2020/4/2
     * @Param [checkId]
     * @return java.lang.Object
     **/

    @ResponseBody
    @PostMapping("/getAllJudgeResult1")
    public Object getAllJudgeResult1(int checkId) {
        return fuzzyService.getAllJudgeResult1(checkId);
    }

    /**
     * 获取每个项目的模糊评价法表格信息
     *
     * @return java.lang.Object
     * @author fanyu
     * @date 2019/9/23 19:08
     * @params [weightResult, checkId]
     */
    @ResponseBody
    @PostMapping("/getAllFuzzyResult")
    public Object getAllFuzzyResult(String weightInfo, int checkId) {
        return fuzzyService.getAllFuzzyResult(weightInfo, checkId);
    }

    /**
     * 修改模糊评价中需要录入的权重
     *
     * @return java.lang.String
     * @author fanyu
     * @date 2019/9/25 15:51
     * @params [fuzzyindicators]
     */
    @ResponseBody
    @PostMapping("/updateFuzzyWeight")
    public String updateFuzzyWeight(Fuzzyindicators fuzzyindicators) {
        return fuzzyService.updateFuzzyWeight(fuzzyindicators);
    }

    /**
     * 生成模糊评价法的评语
     *
     * @return java.lang.Object
     * @author fanyu
     * @date 2019/9/25 17:14
     * @params [param]
     */
    @ResponseBody
    @PostMapping("/getFuzzyConclution")
    public Object getFuzzyConclution(String param, int checkId, String weightInfo) {
        return fuzzyService.getFuzzyConclution(param, checkId, weightInfo);
    }

    @ResponseBody
    @PostMapping("/addZj")
    public String addZj(Specialistinfo zj) {
        return fuzzyService.addZj(zj);
    }

    @ResponseBody
    @PostMapping("deleteZj")
    public String delete(int mkey) {
        return fuzzyService.deleteZj(mkey);
    }

    @ResponseBody
    @PostMapping("deleteItem")
    public String deleteItem(int id, int specialistId,int id3) {
        return fuzzyService.deleteItem(id, specialistId,id3);
    }

    /**
     * 搜索模糊聚类的项目各风险信息
     *
     * @return java.lang.Object
     * @author fanyu
     * @date 2019/10/15 20:14
     * @params [check, clusterType]
     */
    @ResponseBody
    @PostMapping("/getFuzzyResultByCheckId")
    public Object getFuzzyResultByCheckId(String check, int clusterType) {
        return fuzzyService.getFuzzyResult(check, clusterType);
    }

    /**
     * 计算模糊聚类的结果，计算方式有两种，1为夹角余弦法，2为数量积法
     *
     * @return java.lang.Object
     * @author fanyu
     * @date 2019/10/22 10:15
     * @params [fuzzyResult, caculateType]
     */
    @ResponseBody
    @PostMapping("/getClusterCaculate")
    public Object getClusterCaculate(String fuzzyResult, int caculateType) {
        return fuzzyService.getClusterCaculate(fuzzyResult, caculateType);
    }

    /**
     * @Author chenhuanru
     * @Description //根据节点深度查询和节点
     * @Date 21:56 2020/3/30
     * @Param [nodeDepth]
     * @return java.lang.Object
     **/
    @ResponseBody
    @PostMapping("/getItemByDepth")
    public List<Object> getItemByDepth(int nodeDepth,int preNum) {
        return fuzzyService.getItemByDepth(nodeDepth,preNum);
    }
    /**
     * @Author chenhuanru
     * @Description //测试
     * @Date 16:33 2020/5/2
     * @Param [judgeinfos]
     * @return java.lang.String
     **/

    @ResponseBody
    @PostMapping("/requestAddJudgeInfo1")
    public String AddJudgeInfo1(String judgeInfos) {
        System.out.println("controller层"+judgeInfos);
        return fuzzyService.AddJudgeInfo1(judgeInfos);
    }
    /**
     * @Author chenhuanru
     * @Description //将文件导入数据，以数组方式传入后台
     * @Date 17:56 2020/5/9
     * @Param [memberShipInfos]
     * @return java.lang.String
     **/

    @ResponseBody
    @PostMapping("/addMemberShipInfo1")
    public String addMemberShipInfo1(String memberShipInfos) {
        System.out.println("controller层"+memberShipInfos);
        return fuzzyService.addMemberShipInfo1(memberShipInfos);
    }

    @ResponseBody
    @PostMapping("/updateIndicatorWeights")
    public String updateIndicatorWeights(String weightData) {

        return fuzzyService.updateIndicatorWeights(weightData);
    }
}
